Skip to content

feat(blobmanager/s3accesspoint): optional managed session policy via PolicyArns#3145

Merged
jiparis merged 2 commits into
chainloop-dev:mainfrom
jiparis:jiparis/s3-ap-optional-session-policy-arn
May 22, 2026
Merged

feat(blobmanager/s3accesspoint): optional managed session policy via PolicyArns#3145
jiparis merged 2 commits into
chainloop-dev:mainfrom
jiparis:jiparis/s3-ap-optional-session-policy-arn

Conversation

@jiparis
Copy link
Copy Markdown
Member

@jiparis jiparis commented May 22, 2026

Summary

Adds an optional Credentials.SessionPolicyARN to the S3-Access-Point CAS backend. When set, the per-request sts:AssumeRole call references a customer-managed IAM policy via PolicyArns instead of inlining a JSON document. Only the ARN string is packed into STS's packed-policy budget that way, leaving more headroom for session tags inherited from the caller principal (IRSA / Pod Identity).

  • The field is opt-in and backwards-compatible: an empty value preserves the existing slim inline session policy. A missing ARN never degrades to an unscoped session that inherits the full BaseRoleARN permissions.
  • Validation rejects non-managed-policy ARNs (S3 ARNs, role ARNs, garbage) at credential-load time so configuration mistakes surface up front rather than as opaque STS errors during upload.
  • The credentials provider's STS dependency is narrowed to a small interface so the AssumeRole call shape can be exercised in tests without a real AWS config.

When the operator uses this path, the managed policy is the action allowlist for the session — chainloop no longer hard-caps actions inline. The policy MUST be at least as restrictive as the inline default (s3:GetObject + s3:PutObject scoped to \${apARN}/object/*). Cross-tenant isolation is unchanged: it lives in the AP resource policy's aws:userid check against the request-context-derived role session name.

AI disclosure

Assisted by Claude (Anthropic).

…PolicyArns

Add an optional Credentials.SessionPolicyARN field. When set, the
per-request sts:AssumeRole call references a customer-managed IAM
policy via PolicyArns instead of inlining a JSON policy document. Only
the ARN counts against STS's packed-policy budget that way, leaving
more headroom for session tags inherited from the caller principal
(IRSA / Pod Identity).

The field is optional and backwards-compatible: when empty, the
backend continues to send the slim inline session policy. A missing
ARN must NOT degrade to an unscoped session that inherits the full
BaseRoleARN permissions, so the inline fallback is always present.

Validation rejects values that are not IAM managed policy ARNs
(e.g. S3 ARNs, role ARNs) at credential-load time rather than
surfacing as opaque STS errors deep in the upload path.

The sts.Client field on sessionCredentialsProvider is narrowed to a
small stsAssumer interface so tests can lock down the AssumeRole call
shape (inline Policy vs PolicyArns) without spinning up a real AWS
config. No production behavior change.

Assisted-by: Claude
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>

Chainloop-Trace-Sessions: ee4385fa-8011-4750-87cd-502097dda8b9
@chainloop-platform
Copy link
Copy Markdown
Contributor

chainloop-platform Bot commented May 22, 2026

AI Session Analysis

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 88% 1 ✅ 0 100% AI / 0% Human 4 +204 / -19 17h30m1s

🟢 88% — 100% AI — ✅ All policies passing

May 21, 2026 15:45 UTC · 17h30m1s · $25.53 · 271 in / 149.8k out · claude-code 2.1.139 (claude-opus-4-7)

View session details ↗

Change Summary

  • Slims inline session policy to resolve STS PackedPolicyTooLarge error
  • Adds optional SessionPolicyARN field to use a managed policy instead of inline policy
  • Tightens ARN validation using AWS SDK arn.Parse after CI review feedback
  • Adds unit tests covering new SessionPolicyARN feature and validation edge cases
  • Narrows stsAssumer interface in provider.go for improved testability

AI Session Overall Score

🟢 88% — Clean fix for STS packed-policy budget with good tests and planning.

AI Session Analysis Breakdown

🟢 90% · alignment

🟢 Optional SessionPolicyARN with inline fallback implemented exactly as user specified, with security tradeoffs documented. · High Impact

🟡 AI self-initiated ARN validation fix after CI flag without waiting for explicit user prompt. · Low Severity

🟢 90% · solution-quality

No notes.

🟢 90% · verification

🟢 PR review flagged permissive ARN validation; AI tightened it, added edge-case tests, and re-ran full suite. · High Impact

🟡 No integration or end-to-end test exercises the real AWS STS PolicyArns path; only unit tests with mocks. · Low Severity

💡 Add an integration test or explicit note that E2E coverage is deferred to infra-level testing.

🟢 88% · scope-discipline

🟡 stsAssumer interface narrowing in provider.go added for testability without explicit user request. · Low Severity

🟢 85% · user-trust-signal

🟡 User interrupted AI mid-action and redirected with explicit stop instruction. · Low Severity

🟡 78% · context-and-planning

🟢 AI diagnosed root cause (IRSA transitive tags / STS packed-policy budget) before any code edits, preventing a wrong fix. · High Impact

🟠 Initial user prompt was a raw error log with no stated constraints, scope boundaries, or fix preferences. · Medium Severity

💡 State desired approach, security constraints, and out-of-scope items upfront to reduce planning overhead.

🟡 No CLAUDE.md or AGENTS.md present; conductor system prompt provided no project-specific guidance. · Low Severity


File Attribution

████████████████████ 100% AI / 0% Human

Status Attribution File Lines
modified ai pkg/blobmanager/s3accesspoint/backend_test.go +80 / -0
modified ai pkg/blobmanager/s3accesspoint/provider_test.go +52 / -0
modified ai pkg/blobmanager/s3accesspoint/backend.go +35 / -14
modified ai pkg/blobmanager/s3accesspoint/provider.go +37 / -5

Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-ee4385 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-ee4385 -
✅ Passed ai-config-no-secrets ai-coding-session-ee4385 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-ee4385 -

Powered by Chainloop and Chainloop Trace

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread pkg/blobmanager/s3accesspoint/provider.go Outdated
@jiparis jiparis requested review from a team and Piskoo May 22, 2026 09:11
Replace the loose prefix-and-substring check with a proper arn.Parse
plus service and resource-type assertions, so configuration mistakes
that previously slipped through (role ARN whose path embeds
":policy/", policy ARN with an empty name, malformed ARNs) are now
rejected at credential-load time instead of surfacing as opaque STS
errors during upload.

Adds AWS-managed-policy ARNs (arn:aws:iam::aws:policy/...) to the
accepted set and locks down the previously-permissive shapes with
table-driven test cases.

Assisted-by: Claude
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>

Chainloop-Trace-Sessions: ee4385fa-8011-4750-87cd-502097dda8b9
@jiparis jiparis merged commit 97a2ccc into chainloop-dev:main May 22, 2026
16 checks passed
@jiparis jiparis deleted the jiparis/s3-ap-optional-session-policy-arn branch May 22, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants